#!/bin/bash


if [ -f /root/.ssh/id_rsa ]; then
	rm -rf /root/.ssh/id_rsa*
fi

ssh-keygen -t rsa  -f "/root/.ssh/id_rsa"  -P  ""  &> /dev/null

if [ -f /root/.ssh/known_hosts ]; then
	rm -rf /root/.ssh/known_hosts
fi


for i in 30 40;do
/usr/bin/expect << eof
set timeout 10
spawn ssh-copy-id  root@192.168.2.$i
expect "(yes/no)?"
send  "yes\n"
expect "password:"
send   "123\n"
expect eof 
eof
done

for i in 30 40;do
	ssh root@192.168.2.$i  hostname;date
done
